/**
 * .
 * Copyright (c) 2013-2018 All Rights Reserved.
 */
package com.unit.test.controller;

import com.unit.test.model.User;
import com.unit.test.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping
    public Boolean add(@RequestBody User u) {
        return userService.save(u);
    }

    @DeleteMapping("/{id}")
    public Boolean delete(@PathVariable Long id) {
        return userService.removeById(id);
    }

    @PutMapping
    public Boolean update(@RequestBody User u) {
        return userService.updateById(u);
    }

    @GetMapping("/{id}")
    public User get(@PathVariable Long id) {
        return userService.getById(id);
    }
}
